#ifndef IGOR_TTIMER
#define IGOR_TTIMER


#include "svl.h"


namespace Igor{

class TTimer {

	private:
        static HANDLE       s_TimerQueue;
        static unsigned int s_TimerCount;

        static void CALLBACK f_TimerCallBack (PVOID _pTimer, BOOLEAN _flag);
    
        HANDLE m_Handle;

    public:

        TTimer (DWORD _start, DWORD _period);
        ~TTimer (void);

        void setTimeOut (DWORD _start, DWORD _period);

        virtual void TTimer_Tick (void) {}
};

};
////////////////////////////////////////////////////////////////////////////////
///**************************************************************************///
////////////////////////////////////////////////////////////////////////////////

namespace svl{


struct TTimer : public TDebug
{
  TTimer(DWORD _start, DWORD _period);
  ~TTimer();
  //
  virtual void TTimer_Tick() {}
private:
  static int CALLBACK TimerProc0() { Get((::TIMERPROC)TimerProc0)->Tick(); return 0;}
  static int CALLBACK TimerProc1() { Get((::TIMERPROC)TimerProc1)->Tick(); return 0;}
  static int CALLBACK TimerProc2() { Get((::TIMERPROC)TimerProc2)->Tick(); return 0;}
  static int CALLBACK TimerProc3() { Get((::TIMERPROC)TimerProc3)->Tick(); return 0;}
  static int CALLBACK TimerProc4() { Get((::TIMERPROC)TimerProc4)->Tick(); return 0;}
  static int CALLBACK TimerProc5() { Get((::TIMERPROC)TimerProc5)->Tick(); return 0;}
  static int CALLBACK TimerProc6() { Get((::TIMERPROC)TimerProc6)->Tick(); return 0;}
  static int CALLBACK TimerProc7() { Get((::TIMERPROC)TimerProc7)->Tick(); return 0;}
  static int CALLBACK TimerProc8() { Get((::TIMERPROC)TimerProc8)->Tick(); return 0;}
  static int CALLBACK TimerProc9() { Get((::TIMERPROC)TimerProc9)->Tick(); return 0;}
  //
  struct TLink
  {
    ::TIMERPROC Proc; TTimer *Timer;
  };
  int idTimer; 
  DWORD start, startTickCount;
  bool En;
  //
  void Tick();
  //
  static TLink links[10];
  //
  static TTimer *Get(::TIMERPROC Proc);
  static ::TIMERPROC New(TTimer *V);
  static void Delete(TTimer *V);

  svl_Except;
};


} 

#endif
 